#python -m data.api_data.api_runreport   文件直接执行代码
from .api_token import get_id,get_time,get_token
from util.time_util import timestran
import requests
import json
with open(r'data\json_data\runreport.json','r',encoding='utf-8') as f:
    data = json.load(f)['api']



def get_reportlist():
    values =[]
    url = 'http://hxzhan.rtcloud.com:32111/tm/report/list'
    headers = {
        'content-type':'application/json; charset=utf-8',
        'Tm-Token':get_token(), 
        'rt-request-ts':get_time(),
        'rt-request-id':get_id()
    }
    json = {'dateRange': ["", ""], 'page': 1, 'limit': 10}
    response = requests.post(url=url,headers=headers,json=json)
    data_list = response.json()['data']['list']
    for elm in data_list:
        for key in data['report']:
            if key == 'type':
                if elm[key] == 1:
                    values.append('周报')
                elif elm[key] == 2:
                    values.append('月报')
                elif elm[key] == 3:
                    values.append('季报')
                elif elm[key] == 4:
                    values.append('半年报')
                elif elm[key] == 5:
                    values.append('年报')
            elif key == 'created_at':
                values.append(timestran(elm[key]))
            else:
                values.append(elm[key])
    return values



